package com.example.action;

import com.example.model.Usermodel;
import com.example.service.Userservice;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;

import java.util.Map;

/**
 * 用户控制层
 */
public class UserAction extends ActionSupport implements SessionAware {

    private Userservice us=new Userservice();

    private Usermodel um;

    public Usermodel getUm() {
        return um;
    }

    public void setUm(Usermodel um) {
        this.um = um;
    }

    private Map<String, Object> session;

    public void setSession(Map<String, Object> session) {
        this.session = session;
    }

    //登陆
    public String login(){
        if(us.login(um)){
            session.put("email", um.getEmail());
            return SUCCESS;
        }else{
            return "error";
        }
    }

    //注册
    public String register(){
        us.Register(um);
        return SUCCESS;
    }

    //重置密码
    public String reloadpwd(){
        us.reloadpwd(um);
        return SUCCESS;
    }


}
